<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let num = Math.floor(Math.random() * 10) + 1
        let trnum
        while (true) {
            trnum = +prompt(`请猜猜生成的随机数是几`)
            if (trnum > num) {
                alert(`数字猜大了`)
            }
            else if (trnum < num) {
                alert(`数字猜小了`)
            }
            else {
                alert(`恭喜你猜对了`)
                break
            }
        }
        document.write(`恭喜你通关成功`)
    </script>
</body>

</html>